//
//  StatusCellBottomView.swift
//  weibo10
//
//  Created by 晁岳山 on 15/10/19.
//  Copyright © 2015年 晁岳山. All rights reserved.
//

import UIKit
import SnapKit
class StatusCellBottomView: UIView {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //懒加载控件
    private var retweetButton: UIButton = UIButton(imageName: "timeline_icon_retweet", fontSize: 12, btnName: " 转发", color: UIColor.darkGrayColor())
    private var commenButton: UIButton = UIButton(imageName: "timeline_icon_comment", fontSize: 12, btnName: " 评论", color: UIColor.darkGrayColor())
    private var likeButton: UIButton = UIButton(imageName: "timeline_icon_unlike", fontSize: 12, btnName: " 赞", color: UIColor.darkGrayColor())
}
// MARK: - 设置布局
extension StatusCellBottomView {
    private func setupUI() {
        backgroundColor = UIColor(white: 0.95, alpha: 1.0)
        addSubview(retweetButton)
        addSubview(commenButton)
        addSubview(likeButton)
        
        //设置自动布局
        retweetButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(self.snp_left)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
        }
        commenButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetButton.snp_right)
            make.top.equalTo(retweetButton.snp_top)
            make.height.equalTo(retweetButton.snp_height)
            make.width.equalTo(retweetButton.snp_width)
        }
        likeButton.snp_makeConstraints { (make) -> Void in
            make.right.equalTo(self.snp_right)
            make.top.equalTo(commenButton.snp_top)
            make.left.equalTo(commenButton.snp_right)
            make.height.equalTo(commenButton.snp_height)
            make.width.equalTo(commenButton.snp_width)
        }
        //添加分割线
        let sepView1 = sepLine()
        let sepView2 = sepLine()
        retweetButton.addSubview(sepView1)
        retweetButton.addSubview(sepView2)
        //设置约束
        let scale = 0.4
        let width = 0.5
        sepView1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetButton.snp_right)
            make.centerY.equalTo(retweetButton.snp_centerY)
            make.height.equalTo(retweetButton.snp_height).multipliedBy(scale)
            make.width.equalTo(width)
        }
        sepView2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commenButton.snp_right)
            make.centerY.equalTo(commenButton.snp_centerY)
            make.height.equalTo(commenButton.snp_height).multipliedBy(scale)
            make.width.equalTo(width)
        }
    }
    
//    分割线的设置  这儿使用函数而没有使用计算型属性的原因就是 程序的可读性更好
    private func sepLine() -> UIView {
        let sepView = UIView()
        sepView.backgroundColor = UIColor.darkGrayColor()
        return sepView
    }
}





